package com.own.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.own.system.entity.Orders;
import com.own.system.mapper.OrdersMapper;
import com.own.system.service.OrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.own.system.vo.query.OrdersQueryVo;
import org.springframework.stereotype.Service;

/**
 *  服务实现类
 * @author anonymous
 * @since 2024-08-26
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {

    @Override
    public IPage<Orders> findOrdersListByPage(IPage<Orders> page, OrdersQueryVo ordersQueryVo) {
        //创建条件构造器
        QueryWrapper<Orders> queryWrapper = new QueryWrapper<Orders>();
        //订单号精准查询
        queryWrapper.like("order_number",ordersQueryVo.getOrderNumber());
        //排序
        queryWrapper.orderByAsc("id");
        return baseMapper.selectPage(page,queryWrapper);
    }

    @Override
    public IPage<Orders> findOrdersListByUserId(IPage<Orders> page, OrdersQueryVo ordersQueryVo) {
        //创建条件构造器
        QueryWrapper<Orders> queryWrapper = new QueryWrapper<Orders>();
        //用户id精准查询
        queryWrapper.eq("user_id",ordersQueryVo.getUserId());
        //订单号模糊查询
        queryWrapper.like("order_number",ordersQueryVo.getOrderNumber());
        //排序
        queryWrapper.orderByAsc("id");
        return baseMapper.selectPage(page,queryWrapper);
    }
}
